package com.example.netdemo.retrofit

sealed class Resource<out T> {
    data class Success<out T>(val data: T) : Resource<T>()
    data class Error(
        val message: String,
        val exception: Throwable? = null
    ) : Resource<Nothing>()
    object Loading : Resource<Nothing>()

    companion object {
        fun <T> success(data: T) = Success(data)
        fun error(message: String, exception: Throwable? = null) = Error(message, exception)
        fun loading() = Loading
    }
}